<?php
include 'db.php';

$lastmessageid=$_GET['mr'];
$sessionid=$_GET['s'];
$type=$_GET['t'];
$a=1;
if($type== "student")
	if(mysql_query("UPDATE sessions SET `studenttime`=NOW() WHERE `sessionid`={$sessionid}"))
		$a=1;
		//echo "Goods";
	else
		$a=0;
	//echo "Bad" . mysql_error();
else 
	if(mysql_query("UPDATE sessions SET `tutortime`=NOW() WHERE sessionid={$sessionid}"))
		$a=1;
	//	echo "Goodt";
	else
		$a=1;
	//echo "Bad".mysql_error();

$q=mysql_query("SELECT * FROM messages WHERE sessionid={$sessionid} AND messageid > {$lastmessageid} ORDER BY `messageid`"); //LIMIT 100
while($data = mysql_fetch_row($q))
	echo "$data[0]-$data[2]: $data[3]".PHP_EOL;
mysql_close($link);
?>
